﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BestCode.Barcode.View
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            txtStringCode.Focus();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int yearLimit = 2014;
            int monthLimit = 6;
            int dayLimit = 30;

            if (DateTime.Now < new DateTime(yearLimit, monthLimit, dayLimit))
            {
                var imgByte = BestCode.Utils.CodeBars.Common.GenerateQRCode(txtStringCode.Text,
                    System.Drawing.Imaging.ImageFormat.Png);
                MemoryStream stream = new MemoryStream(imgByte);

                BitmapImage image = new BitmapImage();
                image.BeginInit();
                image.StreamSource = stream;
                image.DecodePixelWidth = 200;
                image.EndInit();
                imgQR.Source = image;
            }

        }
    }
}
